<template>
  <view>
    <u-calendar
      :show="isShowDate"
      mode="range"
      @confirm="onConfirm"
      :minDate="minDate"
      :maxDate="maxDate"
      :monthNum="monthNum"
      maxRange="60"
      @close="onClose"
      allowSameDay
    />
  </view>
</template>

<script>
export default {
  props: {
    isShowDate: {
      type: Boolean,
      default: false,
    },
    minDate: {
      type: String,
      default: "2021-01-01",
    },
    maxRange: {
      type: String || Number,
      default: "60",
    },
  },
  data() {
    return {
      maxDate: uni.$u.timeFormat(new Date(), "yyyy-mm-dd"),
      monthNum:
        parseInt(uni.$u.timeFrom(new Date(this.minDate), "yyyy-mm-dd")) * 12,
    };
  },
  methods: {
    onClose() {
      this.$emit("update:isShowDate", false);
    },
    onConfirm(e) {
      this.$emit("confirm", e);
      this.$emit("update:isShowDate", false);
    },
  },
};
</script>

<style></style>
